Ext.ns("Ext.jn.Win1");

Ext.jn.Win1 = Ext.extend(Ext.Panel, {
			constructor : function(config) {
				config = Ext.apply({
					title : "已有模板列表",
					layout : "form",
					plain : true
					}, config);
				Ext.jn.Win1.superclass.constructor.call(this, config);
			},
			initComponent : function() {
				this.items = [this._createGrid()];
				Ext.jn.Win1.superclass.initComponent.call(this);
			},
			_createGrid : function() {
				var pageSize = 10;
				var thisId = this.id;
				var cm = new Ext.grid.ColumnModel([
				{
					header : "监控名称",
					dataIndex : "a",
					width : 10,
					sortable : true //允许排队,默认false.
				},
				{
					header : "功能描述",
					dataIndex : "b",
					width : 20
				}, {
					header : "运行脚本名称",
					dataIndex : "c",
					width : 10
				}, {
					header : "文件存放路径",
					dataIndex : "d",
					width : 20
				}, {
					header : "执行脚本用户名",
					dataIndex : "e",
					width : 20
				},{
					header : "IJOBS用户账户",
					dataIndex : "f",
					width : 10
				},{
					header : "监控周期",
					dataIndex : "g",
					width : 10
				}]);

				var store = new Ext.data.JsonStore({
					id : thisId + "storeGrid",
					url:"http://jn/PHPSample/javaData/php_json.php",
					method: "POST",
					autoLoad : true,
					root: 'root',
					totalProperty: "total",
					fields:["a","b","c","d","e","f","g"],
					baseParams: {
						start: 0,
						limit: pageSize
					}
				});

				var grid = new Ext.grid.GridPanel({
					id : thisId + "grid",
					autoHeight:true,
					anchor:"100%",
					cm : cm,
					store : store,
					viewConfig : {
						forceFit : true
					},
					bbar : new Ext.PagingToolbar({
						pageSize : pageSize,
						store : store
					})
				});
				
				return grid;
			}
		});

Ext.jn.Win1Action = Ext.extend(Ext.jn.Win1, {
	
	COMPONENTS : {},
	
	INIT_COMPONENTS : function() {
		var cmp = this.COMPONENTS;
		var thisId = this.id;
		cmp.grid = Ext.getCmp(thisId + "grid");
		cmp.storeGrid= Ext.StoreMgr.get(thisId + "storeGrid");
	},
	
	constructor : function(config) {
		// 执行父类构造方法
		Ext.jn.Win1Action.superclass.constructor.call(this, config);
		// 获取组件集合
		this.INIT_COMPONENTS();
	}
	
});

Ext.onReady(function() {
	var _panel = new Ext.jn.Win1Action();
	new Ext.Viewport({
		renderTo:Ext.getBody(),
		layout:"border",
		items:[{
			autoScroll:true,//最外层的去加上这个属性
			region:"center",
			items:[_panel]
		}]
	})
});